#!/bin/sh
sysName=$1
serverIP=$2
confGitBranch=$3
percent=1
confDir=/srv/salt/prod/nginx/files/nginx-config-dir/vhosts_net

sed -i -r "s/[0-9]{1,}%\s*${sysName}_gray;/${percent}% ${sysName}_gray;/g" $confDir/${sysName}.conf
sed -i "s/proxy_pass.*${sysName}.*;/proxy_pass http:\/\/${sysName}_default;/g" $confDir/${sysName}.conf

salt -N 'deploy' cmd.run "bash d:\\scripts\\fullRelease.sh $sysName $serverIP $confGitBranch"
salt -N 'ngxonline' state.highstate
salt -N 'ngxonline' cmd.run 'nginx -t'
salt -N 'ngxonline' cmd.run 'nginx -s reload'
